package cn.wikiflyer.beikang.act.home;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;
import cn.wikiflyer.beikang.IApplication;
import cn.wikiflyer.beikang.R;
import cn.wikiflyer.beikang.bean.HomeBean.ActivityBean;
import cn.wk.libs4a.view.WKWebAct;

public class HomeBottom {

	private View mView;
	private Context context;
	private ArrayList<ActivityBean> mDatas;
	private int ids[] = new int[] { R.id.img_01, R.id.img_02, R.id.img_03 };

	private IApplication app() {
		return (IApplication) context.getApplicationContext();
	}

	public HomeBottom(Context context, View mView,
			ArrayList<ActivityBean> mDatas) {
		super();
		this.context = context;
		this.mView = mView;
		this.mDatas = mDatas;

		updateUI();
	}

	/**
	 * 刷新界面
	 */
	private void updateUI() {
		try {
			for (int i = 0; i < mDatas.size(); i++) {
				mView.findViewById(ids[i]).setVisibility(View.VISIBLE);
				ActivityBean mActBean = mDatas.get(i);
				final IntentBean mIBean = new IntentBean(mActBean.title,
						mActBean.thumb, mActBean.description,
						mActBean.inputtime, mActBean.catid, mActBean.id);
				app().imageLoader.displayImage(mIBean.thumb,
						(ImageView) (mView.findViewById(ids[i])));
				mView.findViewById(ids[i]).setOnClickListener(
						new OnClickListener() {
							public void onClick(View v) {
								Intent mIntent = new Intent(context,
										NewsAct.class);
								mIntent.putExtra("bean", mIBean);
								mIntent.putExtra("title", "主题活动");
								context.startActivity(mIntent);
							}
						});
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
